package io.gitee.zhangbinhub.admin.common.base

import io.gitee.zhangbinhub.admin.common.event.CloudBusEventContent
import org.noear.snack4.ONode
import org.noear.solon.cloud.model.Event

abstract class BaseCloudEvent {
    var content: CloudBusEventContent = CloudBusEventContent()

    constructor(cloudBusEventContent: CloudBusEventContent) {
        this.content = cloudBusEventContent
    }

    fun toEvent(): Event = Event(getTopic(), ONode.serialize(content)).apply {
        this.group(getTopic())
    }

    abstract fun getTopic(): String
}